<template>
    <div class="content">
        <div class="top">
            <h2>网易云音乐</h2>
            <router-link class="ipt" to="/about">
                <img src="../../assets/imgs/搜索.png" alt="" />
                <span>搜索歌曲</span>
            </router-link>
        </div>

        <!-- 飙升榜单 -->
        <div class="main" v-show="i < 4" v-for="(item, i) in list" :key="i">
            <img :src="item.coverImgUrl" alt="" />

            <router-link class="list_a" :to="'/center/' + item.id"
                ><ol class="list">
                    <li v-for="(item, i) in item.tracks" :key="i">
                        <span>{{ i + 1 }}.</span>
                        <span>{{ item.first }}</span>
                        -
                        <span>{{ item.second }}</span>
                    </li>
                </ol>
            </router-link>
        </div>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            list: [],
        }
    },
    methods: {
        getList() {
            axios({
                url: 'http://114.116.29.103:3000/toplist/detail',
                method: 'GET',
            }).then((res) => {
                console.log(res, '歌曲数据')
                this.list = res.data.list
            })
        },
    },
    mounted() {
        this.getList()
    },
}
</script>

<style scoped>
.content {
    width: 100vw;
    height: 100vh;
}
.top {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ipt {
    width: 96%;
    height: 40px;
    line-height: 40px;
    border-radius: 20px;
    background: #f1f1f1;
    text-indent: 10px;
    text-decoration: none;
    color: #000;
    font-size: 18px;
    display: flex;
    align-items: center;
}
.ipt img {
    width: 30px;
    height: 30px;
    margin-left: 10px;
}
h2 {
    padding: 20px 0;
    text-align: center;
}
.main {
    width: 100%;
    height: 140px;
    margin: 14px;
    display: flex;
}
.main img {
    width: 34%;
    height: 100%;
}
.list_a {
    width: 100px;
    text-decoration: none;
    color: #000;
    width: 66%;
    display: flex;
    flex-direction: column;
}
.list li {
    display: flex;
    padding: 12px;
    align-items: center;
}
.list li span {
    white-space: nowrap; /* 禁止换行 */
    overflow: hidden;
    text-overflow: ellipsis; /* 使用省略号代替超出部分 */
}
</style>
